package dao

import (
	"miao/config"
	"miao/models"
)

func SaveFile(oss models.SysOSS) error {
	config.DB.Create(&oss)
	return nil
}

func PageFile(currentPage int, pageSize int, fileName string) ([]models.SysOSS, int64, error) {
	var roles []models.SysOSS
	var total int64
	offset := (currentPage - 1) * pageSize
	config.DB.Where("file_name LIKE ?", "%"+fileName+"%").Limit(pageSize).Offset(offset).Find(&roles).Count(&total)
	return roles, total, nil
}

func DeleteById(id string) error {
	config.DB.Where("id = ?", id).Delete(&models.SysOSS{})
	return nil
}
